Saturday, May 31, 2008

No vhost.conf in httpd.include OR Changing default DocumentRoot directory

I have Plesk installed as server management tool and I wanted to point multiple site to
single DocumentRoot for that purpose I opend httpd.include (for plesk normally present
in /var/www/vhsots//conf). There was a note that you should over ride the
setting in vhost.conf if u want, but there was no vhost.conf in the /conf directory
hence I created it (vi vhost.conf) and enter following code in it

DocumentRoot /path/to/new/documentroot


php_admin_flag engine on
php_admin_flag safe_mode on
php_admin_value open_basedir "/path/to/new/documentroot:/tmp"


and restarted my server, but changes didnt reflect hence I googled and found following
solution.

If you dont find following "Include /var/www/vhosts/conf/conf/vhost.conf" line
in httpd.include then run following command

/usr/local/psa/admin/sbin/websrvmng --reconfigure-vhost --vhost-name=yourdomain.com

Plesk will add "Include" statement in httpd.include

And restart the server (service httpd restart OR /etc/init.d/httpd restart)

And Cheers..

---

I have found one more solution which is I can say technical cheating :) by creating
symbolic link

you remove any custom changes in your vhost.conf file and remove or rename the httpdocs directory entirely.

Then you run ln -s /path/to/new/documentroot httpdocs which will create the link.

This way Apache will still read from /path/to/old/documentroot and all the

settings will apply correctly, but the files are actually stored on the new path.

5 comments:

Anonymous said...

it really reads it, but it does not execute the php files.

Any advice?

mzeecedric said...

Hi, I have the same problem as José, php files are not executed. Any hints on how to achieve this with vhost.con and plesk?

ionline said...

Thank you so much man ... top marks ... that was the solution I was looking for

ion

Carl Parrish said...

The issue here lies in the fact that PHP is enabled by Plesk in httpd.include on a per-directory basis. By default, this is for /var/www/vhosts/(domain)/httpdocs (and below).

Thus, without explicitly turning on PHP in a container for the new document root, PHP files are not processed as PHP but rather as plain text.

So modify the vhost.conf file to read as follows:


php_admin_flag engine on
php_admin_flag safe_mode off

Deric Braito said...

I just struggled with this for a few hours... googled for vhost.conf documentroot php not executing php broken vhost breaks php, and there was nothing. So now theres that.

Anyway, in addition to setting
DocumentRoot /var/www/vhosts/NEWDOMAIN.com/httpdocs

I had to also put

< Directory /var/www/vhosts/NEWDOMAIN.com/httpdocs >

AND NOT

< Directory /var/www/vhosts/OLDDOMAIN.com/httpdocs >

What threw me is the path for this directory is not the old directory from the httpd.include file, but the existing document root that you are pointing to. BTW, your open_basedir directives go inside of this directory tag.

This switched php execution back on finally... Drupal Multisite!!